package com.esl.action.admin;

import java.util.Map;

import javax.annotation.Resource;

import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.json.annotations.JSON;
import org.springframework.stereotype.Controller;

import com.esl.action.CommonAction;
import com.esl.dto.admin.Report_Dto;
import com.esl.service.admin.ReportManager;
import com.esl.service.admin.UserManager;
//@Controller
@Result(name = "tolist", location = "report?jump_url=list", type = "redirect")
public class ReportAction extends CommonAction {

	private Report_Dto report_Dto = new Report_Dto();
	private ReportManager reportManager;
	private UserManager userManager;
	private Map<String, Object> session = getSession();

	public String add() {
		reportManager
				.add(report_Dto.toReport(userManager.getUserByID(getUid())));
		return "tolist";
	}

	public String load() {
		setPageInfo_Dto(reportManager.load(1, 5, "", ""));
		return "success";
	}

	public String report() {
		return "report";
	}

	/*--------------------------------*/
	@JSON(serialize = false)
	public Report_Dto getReport_Dto() {
		return report_Dto;
	}

	public void setReport_Dto(Report_Dto report_Dto) {
		this.report_Dto = report_Dto;
	}

	/*--------------------------------*/
	@Resource
	public void setUserManager(UserManager userManager) {
		this.userManager = userManager;
	}

	@Resource
	public void setReportManager(ReportManager reportManager) {
		this.reportManager = reportManager;
	}
}
